package main

import (
	"fmt"
	"log"
	"net/url"
)

func main() {
	u, err := url.Parse("http://bing.com/search?q=dotnet")
	if err != nil {
		log.Fatal(err)
	}

	u.Scheme = "https"
	u.Host = "google.com"

	q := u.Query()
	q.Set("q", "golang")

	u.RawQuery = q.Encode()
	fmt.Println(u)
	//https://google.com/search?q=golang

	u2, err2 := url.Parse("https://example.com/foo%2fbar")
	if err2 != nil {
		log.Fatal(err2)
	}
	fmt.Println(u2.Path)
	fmt.Println(u2.RawPath)
	fmt.Println(u2.String())
	///foo/bar
	///foo%2fbar
	//https://example.com/foo%2fbar
}
